package com.liuyjy.encryptDecrypt;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

public class CryptoScalarSerializer extends JsonSerializer<Object> {
    @Override
    public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        // 假设 encrypt 是一个加密方法
        String encryptedValue = encrypt(value.toString());
        gen.writeString(encryptedValue);
    }

    private String encrypt(String value) {
        // 实现加密逻辑
        return "encrypted_" + value;
    }
}